//
//  HotCarDetailViewController.m
//  CarWorld
//
//  Created by yuyu on 15/3/28.
//  Copyright (c) 2015年 CarWorldTeam. All rights reserved.
//

#import "HotCarDetailViewController.h"
#import "HotCarDetailView.h"
#import "HotCarDetailCell.h"
@interface HotCarDetailViewController ()

@end

@implementation HotCarDetailViewController

- (void)dealloc
{
    [_segmentedControl release];
    [_tableView release];
    [super dealloc];
}

- (void)loadView
{
    HotCarDetailView *view = [[HotCarDetailView alloc] init];
    view.tableView.delegate = self;
    view.tableView.dataSource = self;
    self.view = view;
    self.segmentedControl = view.segControl;
    self.tableView = view.tableView;
    [view release];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"车型详情";
    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(NSIntegerMin, NSIntegerMin) forBarMetrics:UIBarMetricsDefault];
    self.view.backgroundColor = [UIColor whiteColor];
    self.tableView.showsHorizontalScrollIndicator = NO;
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 140)];
    view.backgroundColor = [UIColor greenColor];
    self.tableView.tableHeaderView = view;
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *keyString = @"HotDetail";
    HotCarDetailCell *cell = [self.tableView dequeueReusableCellWithIdentifier:keyString];
    if (cell==nil) {
        cell = [[HotCarDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:keyString];
    }
    cell.textLabel.text = @"yuyu";
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 140;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 20;
}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view = [[[UIView alloc] init] autorelease];
    float fcolor = 0.95;
    view.backgroundColor = [UIColor colorWithRed:fcolor green:fcolor blue:fcolor alpha:1.0];
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, self.tableView.frame.size.width-10, 10)];
    titleLabel.text = [NSString stringWithFormat:@"第%d分区",section];
    titleLabel.font = [UIFont systemFontOfSize:12];
    [view addSubview:titleLabel];
    [titleLabel release];
    return view;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
